<script setup>

import ToolButtonList2 from "../tools/toolButtonList2.vue";
import SvgIcon from "../../../Svglcon.vue";
import {ref} from "vue";
import HueSliderRed from "../tools/hueSliderRed.vue";
import HueSliderGreen from "../tools/hueSliderGreen.vue";
import HueSliderBlue from "../tools/hueSliderBlue.vue";

const materialPicture = ref('https://dummyimage.com/400/000000/ffffff')
const texturePicture = ref('https://dummyimage.com/1600/ffffff/000000')

const normalIntensity = ref('')
const roughness = ref('')
const metalness = ref('')
const specularHighlights = ref('')
const value = ref('')

const options = [
  {
    value: 'Option1',
    label: '漫反射',
  },
  {
    value: 'Option2',
    label: '漫反射',
  },
  {
    value: 'Option3',
    label: '漫反射',
  }
]
const redValue = ref('FF')

const greenValue = ref('FF')
const blueValue = ref('FF')


const materialList = ref([
  {
    name: '玻璃',
    url: 'https://dummyimage.com/400/000000/ffffff',
  },
  {
    name: '布纹',
    url: 'https://dummyimage.com/1600/ffffff/000000',
  },
  {
    name: '玻璃',
    url: 'https://dummyimage.com/400/000000/ffffff',
  },
  {
    name: '布纹',
    url: 'https://dummyimage.com/1600/ffffff/000000',
  },
  {
    name: '玻璃',
    url: 'https://dummyimage.com/400/000000/ffffff',
  },
  {
    name: '布纹',
    url: 'https://dummyimage.com/1600/ffffff/000000',
  },


])
const textureList = ref([
  {
    name: '玻璃',
    url: 'https://dummyimage.com/400/000000/ffffff',
  },
  {
    name: '布纹',
    url: 'https://dummyimage.com/1600/ffffff/000000',
  },
  {
    name: '玻璃',
    url: 'https://dummyimage.com/400/000000/ffffff',
  },
  {
    name: '布纹',
    url: 'https://dummyimage.com/1600/ffffff/000000',
  },
  {
    name: '玻璃',
    url: 'https://dummyimage.com/400/000000/ffffff',
  },
  {
    name: '布纹',
    url: 'https://dummyimage.com/1600/ffffff/000000',
  },


])

function handleRedUpdate(newRedValue) {
  redValue.value = compute16String(newRedValue);

};

function handleGreenUpdate(newGreenValue) {
  greenValue.value = compute16String(newGreenValue);

};

function handleBlueUpdate(newBlueValue) {
  blueValue.value = compute16String(newBlueValue);
};


function compute16String(decimal) {
  return Number(decimal).toString(16).padStart(2, '0').toUpperCase();
}


</script>

<template>
  <div class="material">
    <div class="iconBars">
      <div class="iconItem">
        <svg-icon name="close" style="zoom:0.9"></svg-icon>
      </div>
      <div class="iconItem">
        <svg-icon name="close" style="zoom:0.9"></svg-icon>
      </div>
    </div>
    <div class="scrollBars">
      <div class="scrollContain">

        <div
            class="pictureCard"
            :style="{ backgroundImage: 'url(' + materialPicture + ')', width: '150px', height: '150px' }"
        >

        </div>

        <div class="scrollSelectList">
          <el-radio-group v-model="materialPicture" size="large">
            <el-radio-button v-for="(item,itemKey) in materialList" :kek="itemKey" :label="item.name" :value="item.url"
                             style="width: 100%"/>
          </el-radio-group>


        </div>


      </div>
    </div>
    <div class="scrollBars">
      <div class="scrollContain">
        <div
            class="pictureCard"
            :style="{ backgroundImage: 'url(' + texturePicture + ')', width: '150px', height: '150px' }"
        >

        </div>
        <div class="scrollSelectList">
          <el-radio-group v-model="texturePicture" size="large">
            <el-radio-button v-for="(item,itemKey) in textureList" :kek="itemKey" :label="item.name" :value="item.url"
                             style="width: 100%"/>
          </el-radio-group>
        </div>

      </div>


    </div>
    <div class="colorSelectBars">
      <div class="materialMangeTitleBar">
        <div>
          <svg-icon name="close"/>
        </div>

        <div class="title">颜色</div>
      </div>
      <div class="inputSelectContain">
        <div class="colorSelectLine">
          <div class="title">
            颜色
          </div>
          <el-select v-model="value" placeholder="" style="width: 90px">
            <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
            />
          </el-select>
          <div>
            #{{ redValue + greenValue + blueValue }}
          </div>


        </div>

        <hue-slider-red @updateRed="handleRedUpdate"></hue-slider-red>
        <hue-slider-green @updateGreen="handleGreenUpdate"></hue-slider-green>
        <hue-slider-blue @updateBlue="handleBlueUpdate"></hue-slider-blue>
      </div>

    </div>
    <div class="parameterSelectBars">
      <div class="materialMangeTitleBar">
        <div>
          <svg-icon name="close"/>
        </div>

        <div class="title">参数</div>
      </div>
      <div class="inputSelectContain">
        <div class="inputField">
          <div class="title">
            法线强度
          </div>
          <div class="" style="width: 118px">
            <el-slider v-model="normalIntensity" :show-tooltip="false"/>
          </div>
          <div>
            <el-input-number
                v-model="normalIntensity"
                :min="0"
                :max="180"
                controls-position="right"
                size="small"
                class="du-el-input-number"
            >
            </el-input-number>
          </div>
        </div>
        <div class="inputField">
          <div class="title">
            粗糙度
          </div>
          <div class="" style="width: 118px">
            <el-slider v-model="roughness" :show-tooltip="false"/>
          </div>
          <div>
            <el-input-number
                v-model="roughness"
                :min="0"
                :max="180"
                controls-position="right"
                size="small"
                class="du-el-input-number"
            >
            </el-input-number>
          </div>
        </div>
        <div class="inputField">
          <div class="title">
            金属度
          </div>
          <div class="" style="width: 118px">
            <el-slider v-model="metalness" :show-tooltip="false"/>
          </div>
          <div>
            <el-input-number
                v-model="metalness"
                :min="0"
                :max="180"
                controls-position="right"
                size="small"
                class="du-el-input-number"
            >
            </el-input-number>
          </div>
        </div>
        <div class="inputField">
          <div class="title">
            镜面高光
          </div>
          <div class="" style="width: 118px">
            <el-slider v-model="specularHighlights" :show-tooltip="false"/>
          </div>
          <div>
            <el-input-number
                v-model="specularHighlights"
                :min="0"
                :max="180"
                controls-position="right"
                size="small"
                class="du-el-input-number"
            >
            </el-input-number>
          </div>
        </div>
      </div>
    </div>
  </div>
  <tool-button-list2></tool-button-list2>
</template>

<style scoped lang="scss">

.material {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding-left: 10px;
  padding-right: 10px;

  .iconBars {
    display: flex;
    height: 50px;
    width: 100%;

    .iconItem {
      width: 50px;
      height: 50px;
      display: flex;
      justify-content: center;
      align-items: center;

    }

  }

  .pictureCard {
    width: 150px;
    height: 150px;
    background-color: red;
  }


  .scrollBars {
    width: 100%;
    height: 160px;
    margin-bottom: 5px;
    border: 1px solid #CCCCCC;
    box-sizing: border-box;
    padding: 5px;

    .scrollContain {
      width: 100%;
      height: 100%;
      display: flex;

      .scrollSelectList {
        flex: 1;
        height: 100%;
        overflow-x: hidden;
        overflow-y: scroll;

        :deep(.el-radio-button__inner) {
          width: 100%;
          border: 0px;
          height: 30px;
          padding: 0px;
          display: flex;
          justify-content: center;
          align-items: center;
        }

        :deep(.el-radio-button__inner:hover) {
          background-color: #3b82f6;
          color: white;
        }

      }
    }
  }

  .inputSelectContain {
    width: 100%;
    height: 150px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-top: 0px;
    margin-bottom: 5px;
    padding: 5px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;

    .colorSelectLine {
      display: flex;
      justify-content: space-around;
      align-items: center;


    }

    .inputField {
      display: flex;
      justify-content: space-around;
      align-items: center;

      :deep(.el-input-number.is-controls-right[class*=small] [class*=decrease], .el-input-number.is-controls-right[class*=small] [class*=increase]) {
        --el-input-number-controls-height: 15px;
      }

      :deep(.el-input-number--small) {
        width: 71px;
        height: 30px;
      }

      :deep(.el-input-number.is-controls-right .el-input__wrapper) {
        padding-left: 0px;
      }

      .title {
        width: 56px;

      }


    }


  }

}

.materialMangeTitleBar {
  display: flex;
  height: 30px;
  justify-content: center;
  align-items: center;
  width: 100%;
  background-color: #EEEEEE;
  border: #CCCCCC 1px solid;

  .title {
    width: 100%;
    font-size: 14px;
    text-align: left;
    color: #999999;
  }
}

</style>